//set 函数可以接收数组作参数，用来初始化
const name = new Set(['zhang','wang','liu','liu']);
console.log(name);      //显示数组
console.log(name.size); //3

//利用set进行数组去重
let arr = [1,4,2,5,6,3,5,3,9,8,7,9,6,5,1,3,4,5,1];
let num = new Set(arr)
console.log(num);    // Set(9) { 1, 4, 2, 5, 6, 3, 9, 8, 7 }
console.log([...num]);
/*[
     1, 4, 2, 5, 6,
     3, 9, 8, 7
   ]*/
